

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=dark>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/my-blog/img/fluid.png">
  <link rel="icon" href="/my-blog/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="木舟">
  <meta name="keywords" content="python Vue Test 测试开发 自动化测试">
  
    <meta name="description" content="前言之前咱们介绍的基本都是ES5的语法，但从2015年开始，JavaScript就会根据实际开发而进行新语法的发布。 这些新语法，极大的提高了开发效率。 接下来就让我们一起去了解他们。  有些语法，之前章节中涉及较多的，就不再详细赘述，只做列举。也会列举一些之前没有讲过，但是在实际开发过程举足轻重的函数  变量声明方式 let const  模板字符串12345678const name &#x3D; &amp;q">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaScript新语法">
<meta property="og:url" content="https://walker_kwu.gitee.io/my-blog/2022/10/23/notes/js/newKnowledge/">
<meta property="og:site_name" content="My Blog">
<meta property="og:description" content="前言之前咱们介绍的基本都是ES5的语法，但从2015年开始，JavaScript就会根据实际开发而进行新语法的发布。 这些新语法，极大的提高了开发效率。 接下来就让我们一起去了解他们。  有些语法，之前章节中涉及较多的，就不再详细赘述，只做列举。也会列举一些之前没有讲过，但是在实际开发过程举足轻重的函数  变量声明方式 let const  模板字符串12345678const name &#x3D; &amp;q">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-10-23T05:41:14.000Z">
<meta property="article:modified_time" content="2023-05-23T10:37:53.257Z">
<meta property="article:author" content="木舟">
<meta property="article:tag" content="测试开发">
<meta property="article:tag" content="测试平台">
<meta property="article:tag" content="javascript">
<meta name="twitter:card" content="summary_large_image">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>JavaScript新语法 - My Blog</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/my-blog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/my-blog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/my-blog/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"walker_kwu.gitee.io","root":"/my-blog/","version":"1.9.2","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/my-blog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/my-blog/js/utils.js" ></script>
  <script  src="/my-blog/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.2.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/my-blog/">
      <strong>木舟</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/my-blog/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="JavaScript新语法"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        木舟
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-10-23 13:41" pubdate>
          2022年10月23日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          5k 字
        
      </span>
    

    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">JavaScript新语法</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：2023年5月23日 晚上
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>之前咱们介绍的基本都是ES5的语法，但从2015年开始，JavaScript就会根据实际开发而进行新语法的发布。</p>
<p>这些新语法，极大的提高了开发效率。</p>
<p>接下来就让我们一起去了解他们。</p>
<blockquote>
<p>有些语法，之前章节中涉及较多的，就不再详细赘述，只做列举。<br>也会列举一些之前没有讲过，但是在实际开发过程举足轻重的函数</p>
</blockquote>
<h1 id="变量声明方式"><a href="#变量声明方式" class="headerlink" title="变量声明方式"></a>变量声明方式</h1><ul>
<li>let</li>
<li>const</li>
</ul>
<h1 id="模板字符串"><a href="#模板字符串" class="headerlink" title="模板字符串"></a>模板字符串</h1><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> name = <span class="hljs-string">&quot;muzhou&quot;</span><br><span class="hljs-keyword">const</span> age = <span class="hljs-number">18</span><br><br><span class="hljs-comment">// 之前的字符串拼接</span><br><span class="hljs-keyword">const</span> sayTextOld = <span class="hljs-string">&quot;我叫&quot;</span> + name + <span class="hljs-string">&quot;, &quot;</span> + <span class="hljs-string">&quot;我今年&quot;</span> + age + <span class="hljs-string">&quot;岁&quot;</span><br><br><span class="hljs-comment">// 模板字符串</span><br><span class="hljs-keyword">const</span> sayTextNew = <span class="hljs-string">`我叫<span class="hljs-subst">$&#123;name&#125;</span>, 我今年<span class="hljs-subst">$&#123;age&#125;</span>岁`</span><br></code></pre></td></tr></table></figure>

<h1 id="Object-assign"><a href="#Object-assign" class="headerlink" title="Object.assign"></a>Object.assign</h1><p>对象属性合并，后面覆盖前面, 没有同名属性则新增</p>
<p>类似python的dict.update</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> a = &#123;<br>    <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;muzhoua&#x27;</span>,<br>    <span class="hljs-attr">age</span>: <span class="hljs-number">1</span><br>&#125;<br><span class="hljs-keyword">const</span> b = &#123;<br>    <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;muzhoub&#x27;</span><br>&#125;<br><span class="hljs-title class_">Object</span>.<span class="hljs-title function_">assign</span>(b, a)<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(b);<br></code></pre></td></tr></table></figure>

<h1 id="Object-hasOwnProperty"><a href="#Object-hasOwnProperty" class="headerlink" title="Object.hasOwnProperty"></a>Object.hasOwnProperty</h1><p>用来判断一个对象是否拥有某个属性</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><br><span class="hljs-keyword">const</span> person = &#123;<br>  <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;muzhou&#x27;</span><br>&#125;<br><br><span class="hljs-comment">// 原型用法</span><br><span class="hljs-comment">// 使用call</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-title class_">Object</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">hasOwnProperty</span>.<span class="hljs-title function_">call</span>(person, <span class="hljs-string">&#x27;name&#x27;</span>));<br><br><span class="hljs-comment">// 对象上使用</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(person.<span class="hljs-title function_">hasOwnProperty</span>(<span class="hljs-string">&#x27;name&#x27;</span>));<br></code></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 注意，hasOwnProperty只能判断本身是否存在属性</span><br><span class="hljs-comment">// 不能判断原型链中的原型是否存在属性</span><br><span class="hljs-title class_">Person</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">name</span> = <span class="hljs-string">&#x27;muzhou&#x27;</span><br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">Person</span>(<span class="hljs-params"></span>)&#123;<br><br>&#125;<br><br><span class="hljs-keyword">const</span> person = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Person</span>()<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(person.<span class="hljs-title function_">hasOwnProperty</span>(<span class="hljs-string">&#x27;name&#x27;</span>)); <span class="hljs-comment">// false</span><br><br></code></pre></td></tr></table></figure>

<h1 id="Array-at"><a href="#Array-at" class="headerlink" title="Array.at"></a>Array.at</h1><p>根据索引获取数组的元素，支持负索引</p>
<p>负索引用法参考python的 <strong>切片</strong></p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>]<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr.<span class="hljs-title function_">at</span>(-<span class="hljs-number">1</span>))  <span class="hljs-comment">// 4</span><br></code></pre></td></tr></table></figure>

<h1 id="Array-includes"><a href="#Array-includes" class="headerlink" title="Array.includes"></a>Array.includes</h1><p>用来判断某元素是否在数组中, 返回true/false</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>]<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr.<span class="hljs-title function_">includes</span>(<span class="hljs-number">1</span>))  <span class="hljs-comment">// true</span><br></code></pre></td></tr></table></figure>


<h1 id="数组解构"><a href="#数组解构" class="headerlink" title="数组解构"></a>数组解构</h1><p>数组解构，就是将数组的元素依次提取到一个新的变量，或一个新的参数</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><br><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>]<br><br><span class="hljs-keyword">const</span> arr1 = [...arr]<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr1);  <span class="hljs-comment">// [1, 2, 3, 4]</span><br><br><span class="hljs-keyword">const</span> arr2 = [...arr, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>]  <br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr2);  <span class="hljs-comment">// [1, 2, 3, 4, 5, 6]</span><br><br><span class="hljs-keyword">const</span> <span class="hljs-title function_">fn1</span> = (<span class="hljs-params">fnArr</span>)=&gt;&#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(fnArr);<br>&#125;<br><br><span class="hljs-title function_">fn1</span>(...arr)  <span class="hljs-comment">// 1  实际上运行的是，fn1(1, 2, 3, 4)</span><br><br><span class="hljs-keyword">const</span> <span class="hljs-title function_">fn2</span> = (<span class="hljs-params">...fnArr</span>)=&gt;&#123;<br>    <span class="hljs-comment">// ...fnArr, 表示的是，将所有参数吸收成一个参数</span><br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(fnArr);<br>&#125;<br><br><span class="hljs-title function_">fn2</span>(...arr) <span class="hljs-comment">// [1, 2, 3, 4]  实际上运行的是，fn1(1, 2, 3, 4)</span><br><br><span class="hljs-keyword">const</span> <span class="hljs-title function_">fn3</span> = (<span class="hljs-params">a, b, ...fnArr</span>)=&gt;&#123;<br>    <span class="hljs-comment">// ...fnArr, 表示的是，将剩余参数吸收成一个参数</span><br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(fnArr);<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(a);<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(b);<br>&#125;<br><br><span class="hljs-title function_">fn3</span>(...arr) <span class="hljs-comment">// fnArr: [3, 4]  a: 1  b : 2</span><br><br><span class="hljs-keyword">const</span> arr3 = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]<br><br><span class="hljs-keyword">const</span> arr4 = [<span class="hljs-number">0</span>]<br><br>arr4.<span class="hljs-title function_">push</span>(...arr3)<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr4);  <span class="hljs-comment">// [0, 1, 2]</span><br><br></code></pre></td></tr></table></figure>


<h1 id="对象解构"><a href="#对象解构" class="headerlink" title="对象解构"></a>对象解构</h1><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> obj1 = &#123;<br>    <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;muzhou&#x27;</span>,<br>    <span class="hljs-attr">age</span>: <span class="hljs-number">18</span>,<br>    <span class="hljs-attr">sex</span>: <span class="hljs-string">&#x27;male&#x27;</span><br>&#125;<br><br><span class="hljs-keyword">const</span> &#123;<br>    name,<br>    age,<br>    sex<br>&#125; = obj1<br><br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(name);  <span class="hljs-comment">// muzhou</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(age);  <span class="hljs-comment">// 18</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(sex);  <span class="hljs-comment">// male</span><br><br><span class="hljs-comment">// 可以单独取一个</span><br><span class="hljs-comment">// 可以额外命名</span><br><span class="hljs-keyword">const</span> &#123;<br>    <span class="hljs-attr">name</span>: myName<br>&#125; = obj1<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(myName);<br></code></pre></td></tr></table></figure>

<h1 id="模块导入"><a href="#模块导入" class="headerlink" title="模块导入"></a>模块导入</h1><p>JavaScript已经支持 <code>import ... from ...</code>的语法，进行模块导入</p>
<p>使用时需要配合 export 来使用</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 默认导出</span><br><br><span class="hljs-comment">// 定义导出的是什么</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> ()=&gt;&#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;defaultFunc&#x27;</span>);<br>&#125;<br><br><span class="hljs-comment">// 导入</span><br><span class="hljs-keyword">import</span> defaultFunc <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./defaultFunc.js&#x27;</span><br><br><span class="hljs-title function_">defaultFunc</span>()<br><br><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-string">&#x27;default&#x27;</span><br><br><span class="hljs-keyword">import</span> defaultText <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./defaultFunc.js&#x27;</span><br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(defaultText);<br></code></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 多变量导出</span><br><br><br><span class="hljs-comment">// 定义导出</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> export1 = <span class="hljs-string">&#x27;export1&#x27;</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">let</span> export2 = <span class="hljs-string">&#x27;export2&#x27;</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">var</span> export3 = <span class="hljs-string">&#x27;export3&#x27;</span><br><br><br><span class="hljs-keyword">import</span> &#123;<br>    export1,<br>    export2,<br>    export3,<br>&#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./xxx.js&#x27;</span><br><br><br><span class="hljs-keyword">const</span> export1 = <span class="hljs-string">&#x27;export1&#x27;</span><br><span class="hljs-keyword">let</span> export2 = <span class="hljs-string">&#x27;export2&#x27;</span><br><span class="hljs-keyword">var</span> export3 = <span class="hljs-string">&#x27;export3&#x27;</span><br><br><span class="hljs-keyword">export</span> &#123;<br>    export1,<br>    export2,<br>    export3,<br>&#125;<br><br><span class="hljs-keyword">import</span> &#123;<br>    export1,<br>    export2,<br>    export3,<br>&#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./xxx.js&#x27;</span><br><br><br><span class="hljs-comment">// 重命名</span><br><br><span class="hljs-keyword">export</span> &#123;<br>    export1 <span class="hljs-keyword">as</span> export11,<br>    export2 <span class="hljs-keyword">as</span> export22,<br>    export3 <span class="hljs-keyword">as</span> export33,<br>&#125;<br><br><span class="hljs-keyword">import</span> &#123;<br>    export11,<br>    export22,<br>    export33,<br>&#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./xxx.js&#x27;</span><br><br></code></pre></td></tr></table></figure>

<h1 id="另一种循环方式-for-…-of"><a href="#另一种循环方式-for-…-of" class="headerlink" title="另一种循环方式 for … of"></a>另一种循环方式 for … of</h1><p><code>for ... of ...</code> 效果和 <code>forEach</code> 类似</p>
<p>不同的是 forEach 不能停止，而 for … of … 可以用break/continue来控制</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>]<br><br><span class="hljs-keyword">for</span>(<span class="hljs-keyword">const</span> el <span class="hljs-keyword">of</span> arr)&#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(el);<br>&#125;<br></code></pre></td></tr></table></figure>

<h1 id="箭头函数"><a href="#箭头函数" class="headerlink" title="箭头函数"></a>箭头函数</h1><h1 id="class"><a href="#class" class="headerlink" title="class"></a>class</h1><p>之前我们说过，在JavaScript中，想要使用构造函数创建对象，来达到 <strong>工厂函数</strong> 的作用，十分麻烦</p>
<p>于是JavaScript引入了 <strong>class</strong></p>
<p>没错，JavaScript也有如python、java那样，可以面向对象编程。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">Person</span> &#123;<br>    <span class="hljs-comment">// 相当于python class 中的 __init__</span><br>    <span class="hljs-comment">// 进行类变量的初始化</span><br>    <span class="hljs-title function_">constructor</span>(<span class="hljs-params">name, age</span>) &#123;<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-property">name</span> = name;<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-property">age</span> = age;<br>    &#125;<br>&#125;<br><br><span class="hljs-keyword">const</span> person = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Person</span>(<span class="hljs-string">&#x27;muzhou&#x27;</span>, <span class="hljs-number">18</span>)<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(person);<br></code></pre></td></tr></table></figure>

<h1 id="异常处理"><a href="#异常处理" class="headerlink" title="异常处理"></a>异常处理</h1><h1 id="promise、async、await"><a href="#promise、async、await" class="headerlink" title="promise、async、await"></a>promise、async、await</h1><h2 id="promise"><a href="#promise" class="headerlink" title="promise"></a>promise</h2><p>Promise 是ES6推出异步编程的一种解决方案，比传统的解决方案——回调函数和事件——更合理和更强大。它由社区最早提出和实现，ES6 将其写进了语言标准，统一了用法，原生提供了Promise对象。</p>
<p>Promise 对象是一个代理对象（代理一个值），被代理的值在 Promise 对象创建时可能是未知的。它允许你为异步操作的成功和失败分别绑定相应的处理方法（handlers）。 这让异步方法可以像同步方法那样返回值，但并不是立即返回最终执行结果，而是一个能代表未来出现的结果的 promise 对象。</p>
<p>Promise对象有以下两个特点：</p>
<ul>
<li>对象的状态不受外界影响 </li>
<li>一旦状态改变，就不会再变，任何时候都可以得到这个结果</li>
</ul>
<p>Promise 接受 一个 函数参数，这个函数参数，需要拥有两个回调函数，一个代表 成功 一个代表 失败</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> <span class="hljs-title function_">fn</span> = (<span class="hljs-params">a</span>)=&gt;&#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>)=&gt;</span>&#123;<br>        <span class="hljs-keyword">if</span> (a == <span class="hljs-number">1</span>)&#123;<br>          <span class="hljs-title function_">resolve</span>(<span class="hljs-string">&quot;我成功了&quot;</span>)<br>        &#125;<span class="hljs-keyword">else</span>&#123;<br>          <span class="hljs-title function_">reject</span>(<span class="hljs-string">&quot;我失败了&quot;</span>)<br>        &#125;<br>    &#125;)<br>&#125;<br><br><span class="hljs-title function_">fn</span>(<span class="hljs-number">1</span>)<br>.<span class="hljs-title function_">then</span>(<span class="hljs-function"><span class="hljs-params">res</span>=&gt;</span>&#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(res);<br>&#125;).<span class="hljs-title function_">catch</span>(<span class="hljs-function"><span class="hljs-params">res</span>=&gt;</span>&#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(res);<br>&#125;).<span class="hljs-title function_">finally</span>(<span class="hljs-function">()=&gt;</span>&#123;<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;不管怎么样，我都执行了&quot;</span>);<br>&#125;)<br><br><span class="hljs-comment">// 结果</span><br><span class="hljs-comment">// 我成功了</span><br><span class="hljs-comment">// 不管怎么样，我都执行了</span><br></code></pre></td></tr></table></figure>

<p>promise 执行的 函数，是 <strong>异步</strong> 的</p>
<p>这意味着你可以用来封装http请求，等待接口返回数据时，可以做一些其他的事情</p>
<p>通常，promise 会和 <strong>axios</strong>、<strong>ajax</strong>搭配使用</p>
<p>后续会在实战部分进行进一步讲解</p>
<h2 id="async-await"><a href="#async-await" class="headerlink" title="async/await"></a>async/await</h2><p>异步回调最终解决方案</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><br><span class="hljs-keyword">const</span> <span class="hljs-title function_">apiFn</span> = (<span class="hljs-params">formData</span>)=&gt;&#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>)=&gt;</span>&#123;<br>        <span class="hljs-comment">// 在这进行接口请求</span><br>        <span class="hljs-keyword">const</span> res = api.<span class="hljs-title function_">get</span>(<span class="hljs-string">&#x27;xxx&#x27;</span>, formData)<br><br>        <span class="hljs-keyword">if</span> (res.<span class="hljs-property">status</span> == <span class="hljs-number">200</span>)&#123;<br>          <span class="hljs-title function_">resolve</span>(res)<br>        &#125;<span class="hljs-keyword">else</span>&#123;<br>          <span class="hljs-title function_">reject</span>(res)<br>        &#125;<br>    &#125;)<br>&#125;<br><br><span class="hljs-keyword">const</span> <span class="hljs-title function_">submit</span> = <span class="hljs-keyword">async</span> (<span class="hljs-params"></span>)=&gt;&#123;<br>  <span class="hljs-keyword">const</span> formData = &#123;&#125;<br>  <span class="hljs-comment">// 有时候，接口的请求，是需要等待的</span><br>  <span class="hljs-comment">// 等待执行结束后执行某些操作</span><br>  <span class="hljs-keyword">const</span> res = <span class="hljs-keyword">await</span> <span class="hljs-title function_">apiFn</span>(formData)<br>&#125;<br><br></code></pre></td></tr></table></figure>

<h1 id="三元表达式"><a href="#三元表达式" class="headerlink" title="三元表达式"></a>三元表达式</h1><p>和python的三元表达式的使用方式不同，但是效果一样</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs python"><br>a = <span class="hljs-number">1</span><br><br><span class="hljs-comment"># 结果 if xx else 另外的结果</span><br><span class="hljs-comment"># if 通过的话，则赋值结果</span><br><span class="hljs-comment"># if 不通过，则赋值另外的结果</span><br>b = a + <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> a == <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span>  <br><br></code></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><br><span class="hljs-keyword">const</span> a = <span class="hljs-number">1</span><br><br><span class="hljs-comment">// 判断 ? 结果 : 另一个结果</span><br><span class="hljs-comment">// 判断通过，则赋值结果</span><br><span class="hljs-comment">// 判断不通过，则赋值另一个结果</span><br><span class="hljs-keyword">const</span> b = a == <span class="hljs-number">1</span> ? a + <span class="hljs-number">1</span> : <span class="hljs-number">0</span><br></code></pre></td></tr></table></figure>
                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/my-blog/categories/%E6%B5%8B%E8%AF%95%E5%BC%80%E5%8F%91/" class="category-chain-item">测试开发</a>
  
  
    <span>></span>
    
  <a href="/my-blog/categories/%E6%B5%8B%E8%AF%95%E5%BC%80%E5%8F%91/javascript/" class="category-chain-item">javascript</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/my-blog/tags/%E6%B5%8B%E8%AF%95%E5%BC%80%E5%8F%91/">#测试开发</a>
      
        <a href="/my-blog/tags/%E6%B5%8B%E8%AF%95%E5%B9%B3%E5%8F%B0/">#测试平台</a>
      
        <a href="/my-blog/tags/javascript/">#javascript</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>JavaScript新语法</div>
      <div>https://walker_kwu.gitee.io/my-blog/2022/10/23/notes/js/newKnowledge/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>木舟</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年10月23日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2023年5月23日</div>
        </div>
      
      <div class="license-meta-item">
        <div>许可协议</div>
        <div>
          
            
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="BY - 署名">
                <i class="iconfont icon-by"></i>
              </span>
              </a>
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="NC - 非商业性使用">
                <i class="iconfont icon-nc"></i>
              </span>
              </a>
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="SA - 相同方式共享">
                <i class="iconfont icon-sa"></i>
              </span>
              </a>
            
          
        </div>
      </div>
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/my-blog/2022/10/29/notes/js/dom/" title="JavaScript Dom操作">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">JavaScript Dom操作</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/my-blog/2022/10/22/notes/js/this/" title="this精讲">
                        <span class="hidden-mobile">this精讲</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <span>By 木舟</span> <i class="iconfont icon-love"></i> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/my-blog/js/events.js" ></script>
<script  src="/my-blog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/my-blog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      headingSelector : CONFIG.toc.headingSelector || 'h1,h2,h3,h4,h5,h6',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      collapseDepth   : CONFIG.toc.collapseDepth || 0,
      scrollSmooth    : true,
      headingsOffset  : -boardTop
    });
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.10/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/my-blog/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/my-blog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
